package com.peng.crm.workbench.util;

import com.peng.crm.settings.dao.DicValueDao;
import com.peng.crm.settings.dao.UserDao;
import com.peng.crm.settings.entity.DicValue;
import com.peng.crm.settings.entity.User;

public class IDSelNameUtil{

    private UserDao userDao;

    private DicValueDao dicValueDao;

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public DicValueDao getDicValueDao() {
        return dicValueDao;
    }

    public void setDicValueDao(DicValueDao dicValueDao) {
        this.dicValueDao = dicValueDao;
    }

    /**
     * 根据用户ID查询用户姓名
     * @param userId
     * @return
     */
    public String getUserName(String userId){
        User user = userDao.selectById(userId);
        if (user != null){
            return user.getName();
        }
        return "查不到该用户姓名";
    }

    /**
     * 根据dicId查询字典值
     * @param dicId
     * @return
     */
    public String getDicText(String dicId){
        DicValue dicValue = dicValueDao.selectById(dicId);
        if (dicValue != null){
            return dicValue.getText();
        }
        return "查不到该字典值";
    }
}
